import { EntitySchema } from '@mikro-orm/core';

export class LePromoter {
  id!: string;
  UID!: string;
  level?: number = 1;
  startLevel?: number = 1;
  commission?: string;
  commissionAmount?: string;
  status?: number = 0;
  note?: string;
  transferId?: string;
  repelTime?: string;
  inviteId!: string;
  applyContent?: string;
  applyTime?: string;
  joinTime?: string;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isDeleted?: number = 0;
  inviteNumber?: number = 0;
}

export const LePromoterSchema = new EntitySchema({
  class: LePromoter,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', index: '用户ID' },
    level: { type: 'number', columnType: 'tinyint', nullable: true, default: 1 },
    startLevel: { type: 'number', columnType: 'tinyint', nullable: true, default: 1 },
    commission: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    commissionAmount: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    status: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
    note: { type: 'string', length: 255, nullable: true },
    transferId: { type: 'string', columnType: 'bigint', nullable: true },
    repelTime: { type: 'string', columnType: 'bigint', nullable: true },
    inviteId: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    applyContent: { type: 'string', columnType: 'text', nullable: true },
    applyTime: { type: 'string', columnType: 'bigint', nullable: true },
    joinTime: { type: 'string', columnType: 'bigint', nullable: true },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
    inviteNumber: { type: 'number', nullable: true, default: 0 },
  },
});
